<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<%@page import="b1w1nn1ng.crossf1t.gui.*, java.util.*, java.sql.*, b1w1nn1ng.crossf1t.business.*"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<title>Edit Profile </title>
		<jsp:include page="/detectBrowser.jsp" />	
	</head>
	<body>
	<%@page import="java.util.*" %>
	<%@page import="b1w1nn1ng.crossf1t.db.*"%>
	<%@page import="b1w1nn1ng.crossf1t.gui.*"%>
	<%@page import="b1w1nn1ng.crossf1t.business.*"%>
	<%
		User user = (User) session.getAttribute("user");
		session.setAttribute("user", user);
		
		if (request.getParameter("newName") != null) {
			String newName = request.getParameter("newName");
			user.setFirstName(newName);
		}
		
		if (request.getParameter("newWeight") != null) {
			String newWeight = request.getParameter("newWeight");
			try{
				user.setWeight(Integer.parseInt(newWeight));
			} catch (Exception e){
			}
		}
		
		if (request.getParameter("newHeight") != null) {
			String newHeight = request.getParameter("newHeight");
			try{
			user.setHeight(Integer.parseInt(newHeight));
			}catch(Exception e){}
		}
	%>
	<div id="container">
	<jsp:include page="/navbar.jsp" />	
		<h1> Edit Profile </h1> <hr />
	
			<table id="settingsTable" style="padding-left: 100px;">
				<tr>
					<td style="text-align:left;">Name: &nbsp; &nbsp;</td>
					<td style="text-align:left;"> <%=  user.getFirstName()  %> </td>
					<td style="text-align:right;">  &nbsp; &nbsp; &nbsp;<a href="profile/profileName.jsp" class="changeButton">Change</a> </td>
				</tr>
				<tr>
					<td style="text-align:left;" >Weight: &nbsp; &nbsp;</td>
					<td style="text-align:left;" > <%= user.getWeight()  %> </td>
					<td style="text-align:right;">  &nbsp; &nbsp; &nbsp;<a href="profile/profileWeight.jsp" class="changeButton">Change</a> </td>
				</tr>
				<tr>
					<td  style="text-align:left;">Height: &nbsp; &nbsp; </td>
					<td  style="text-align:left;">  <%= user.getHeight()  %> </td>
					<td style="text-align:right;"> &nbsp; &nbsp; &nbsp; <a href="profile/profileHeight.jsp" class="changeButton">Change</a> </td>
				</tr>
				<tr>
					<td  style="text-align:left;">BMI: </td>
					<td  style="text-align:left;"> <%= user.calculateBMI()  %>  </td>
				</tr>
			</table>	
		</div>
	</body>
</html>
